package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.entity.Gowuche;

import java.util.List;

@Mapper
public interface Gowuchemapper {
    /**
     * 新增
     * @param gowuche
     */
    int xz(Gowuche gowuche);

    /**
     * 查询
     * @param productId
     * @param selectedSpecs
     * @return
     */
    @Select("select * from gowuche where product_id=#{productId} and selected_specs=#{selectedSpecs}")
    Gowuche cx(Long productId, String selectedSpecs);

    /**
     * 修改
     * @param id
     */
    @Update("update gowuche\n" +
            "SET quantity=quantity+1\n" +
            "WHERE id = #{id};")
    void xg(int id);

    /**
     * 购物车查询
     * @param username
     * @return
     */
    @Select("select * from gowuche where username=#{username}")
    List<Gowuche> cxs(String username);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from gowuche where id=#{id}")
    void sc(int id);

    /**
     * 注销
     * @param username
     */
    @Delete("delete from gowuche where username=#{username}")
    void zx(String username);
}
